<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>精选板块</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">						
			#towriter{
				border: 0px solid #555555;
				white-space: normal;											
			}
			#towriter1{
				border: 0px solid #555555;
				white-space: normal;											
			}
			#towriter2{
				border: 0px solid #555555;
				white-space: normal;											
			}
			.fixedBox{					
				white-space: nowrap;
				background-color:#000;
			}
			.fixedBox::-webkit-scrollbar {
				width: 0px;     
				height: 0px;		
				background-color:#7c7c7c;		
			}	
			
			p {margin:0px}
			
			div {
				margin:0px;
				padding-left: 0px;
			}
			/*#towrite1 {margin-top:3px}
			towrite2 {margin:-10px}			
			p {margin:0px}
			ul {margin:0px}			
			h4 {margin-top:0px}*/
			table{
			width:200px; 
			border-collapse:collapse; 
			text-align:center;
			}
			td,th{border:1px solid #040404}	
		</style>		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script>
		<script>

			var 封占比=0.1  //封单占实际流通市值的比值 大于 门限时 标红	

			var cybcolor = "#2F4F6F";  //创业板颜色
			var kcbcolor = "#2F4F3F";  //科创板颜色

			//位置
			var 左宽="265px";
			var 涨停数的位置="83px"; //调大 左移动
			var 高标位置="-13px";
			var N天N板="26px";
			var 右宽="210px";

			//显示小于 实际流通标签
			var 实际流通标签=20;
			var 实际流通标签颜色="#58aeef";
			

			//显示的成分数量  ,若 实际小于 "成分数量" 则按 成分最多显示
			var 成分数量=1000;

			//显示n个概念
			var nNum=50; //取40个数据,一般不设置这个值，除非 显示的数据 要比取数大
			var nnNum=44; //显示38个。

			//选中的颜色
			var 选中的颜色="#800000";

			//主板涨幅大于5数
			var 主板涨幅大于5数颜色="#f00000";  
			var 创业板涨幅大于10数颜色="#ffaa00";

		
			var dt = "";
			var tt = "";
			var gt = "";
			var k = "0";
			window.onload = function() {
				var day = new Date();
				gt = day.getTime();			
				mymonth = day.getMonth()+1;
				myday = day.getDate();
				if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
				if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
				tt = day.getFullYear() + "-" + mymonth + "-" + myday;	
				dt = tt;
				getSource();
				changeStyle();			
			}
						
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					getSource();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}

			//执行时间范围
			function time_range_run(beginTime, endTime) { 
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}
   　　　
			$(function() {
				setInterval(function() {

					const dayOfWeek = (new Date()).getDay();
					var kkr=0;
					//今天是星期六或者星期日
					if (dayOfWeek === 0 || dayOfWeek === 6) {
						kkr=1;
					}  
					
					if(kkr === 0){
						time_range("9:15","11:30")
						time_range("13:00","14:57")	 
						time_range("15:00","15:01")	 
					}

				},
				10000);
			})
			
			Date.prototype.Format = function (fmt) {
			var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
			};
			
			if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function changeStyle() {
				var obj = document.getElementById("towriter");		
				obj.style.marginTop= "-10px";			
				obj.style.left= "0px"; 				
				obj.style.width= 左宽;	//左侧宽度
				obj.style.height= "100%";	
				obj.style.borderLeft= "1px solid #968d8d80";

				var obj1 = document.getElementById("towrite1");		
				obj1.style.paddingLeft= "0px"; 		
				obj1.style.width= 左宽;	//左侧宽度
				obj1.style.fontSize="12px";	//左侧字体 
				
				var obj2 = document.getElementById("towrite2"); 
				obj2.style.left= 左宽;   //右侧左边位置
				obj2.style.width= 右宽;  //右侧宽度
				obj2.style.fontSize="12px";	//右侧字体		  
				obj2.style.height= "100%";		
				obj2.style.marginTop= "-10px";
				obj2.style.border="0px solid #968d8d80";		  
				obj2.style.borderLeft="1px solid #968d8d80";
			}
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};
			
			function createXmlHttp() {
				if (window.XMLHttpRequest) {
				xmlHttp1 = new XMLHttpRequest();
				xmlHttp2 = new XMLHttpRequest();
				//xmlHttp3 = new XMLHttpRequest();
				} else {
				xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
				//xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}			
									
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function BookingRmk(date){         
				tt = date;
				var date1 = new Date(tt);
				var date2 = new Date(dt);						
				k = 0;
				if(date1.getTime() < date2.getTime()){			
					k = 1;
					tradeday();
				}								
				getSource();						
			}

			function tradeday() {  //判断最后交易日
				var day = new Date(tt);							
				for (i = 1; i < 100; i++){	//节假日																										
					if(i > 1){
						day.setTime(day.getTime() - 24*60*60*1000);							
					}	
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=60&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt; 			
					var xhr = new XMLHttpRequest();	
					xhr.open("GET", url, false);//同步 
					xhr.send(null)																										
					var data = xhr.responseText;
					//document.write(data);
					if(data.indexOf("MYSQL数据库链接出错!") == -1){						
						break;
					}
				}
			}
			
			function UnUnicode(str) {
				return unescape(str.replace(/\\/g, "%"));
			}
			
			function getSource() {	
				div = document.getElementById('towrite1');																
				div.innerHTML = '<font size="3">日期&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><input style="height: 15px;width: 90px;margin-bottom:10px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';		
				
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st="+nNum+"&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&"; 
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st="+nNum+"&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt; 			
				var url = url1;
				if(k == "1"){
					url = url2;
				}				
				createXmlHttp();				
				xmlHttp1.onreadystatechange = writeSource;
				xmlHttp1.open("GET", url, true);
				xmlHttp1.send(null);				
			}

			function writeSource() { 
				if (xmlHttp1.readyState == 4) { 
					div1 = document.getElementById('towrite1');					
					var data1 = xmlHttp1.responseText								
					//document.write(data1);
					if(k == 0){
						tt = data1.match(/Day":\["(\S*)"\],"Min"/)[1];						
						dt = tt;
					}
					if(data1.indexOf("MYSQL数据库链接出错!") == -1)	{
						data1 = data1.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
						data1 = data1.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"qd":'+str.split(',')[2]+',"zf":'+str.split(',')[3];});
						data1 = data1.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]}");
						//document.write(data1);						
						ss = data1.split('},{');	
						let codeArray = [];			
						var n = 1;
						for (i = 0; i < ss.length; i++){
							
							var code = ss[i].match(/\"code\":\"(\S*)\",\"name/)[1];							
							var name = ss[i].match(/\"name\":\"(\S*)\",\"qd/)[1];
							name = cutStr(UnUnicode(name).replace('概念','').replace('.','').replace('增长','').replace('新型','新').replace(/%/g,'').replace(/\//g,'\\'),10); 
							var qd = ss[i].match(/\"qd\":(\S*),\"zf/)[1];
							var zf = ss[i].match(/\"zf\":(\S*)/)[1].replace("}]}","");	
							codeArray.push(code.trim()+"."+name);
							if(name.indexOf("ST") == -1){	
								if(n-1 == nnNum){
									break;  //这里的n是定义左边板块的个数
								}				
								var bks = "<a href='javascript:void(0)' id='bk" + name + "' onclick='changeCss(this,\"towrite1\");update(" + "\"" +
								//var bks = "<td><a id='bk" + name + "' onclick='changeCss(this,\"towrite1\");update(" + "\"" +
										code + "\"+\"#\"+" + "\"" + name + "\"" + ")'>" + n + "、" +
										 "&nbsp;" + name + "</a></td>"	;
										 //+ "&nbsp;" + qd + "</a>"	;
										//qd + "&nbsp;" + keepTwoDecimal(zf) + "%" + "</a>"	;

								var zfx = "<td><a href='javascript:void(0)' id='jpzt"+code+"' style='position:absolute; right:-10px;' href='javascript:void(0)' onclick='update(" + "\"" +
										code + "\"+\"#\"+" + "\"" + name + "\"" + ")'>" + "&nbsp;" + qd + "&nbsp;" + keepTwoDecimal(zf) + "%" + "</a></td>";	
								
								var zfx2 = "<td><a id='jpzt"+code+"' style='position:absolute; right:-10px;'>" + "&nbsp;" + qd + "&nbsp;" + keepTwoDecimal(zf) + "%" + "</a></td>";	
								var bkdm = code;																	
								subclass(bkdm,bks+zfx);		
								n++;											
							}
							if(n == 1 && name.indexOf("ST") == -1 && y == 1){
								temp = code + ";";
								if((olddm + "#" + oldbk).trim()=="#"){
									update(code + "#" + name);
								}else{
									update(olddm + "#" + oldbk);
								} 
							}
						}

						//统计涨停数量
						setTimeout(loop, 100);
						var m = 0;
						function loop(){
							var code = codeArray[m];	
							m++;
							// //涨停数 统计
							// if (time_range_run("09:15","11:25")){

							// 	jjiabkgg(code);  //竞价统计

							// }else{
							// 	//涨停数 统计
							// 	bkgg(code);   //替换 涨停股 的位置
							// }
							
							bkgg(code);   //替换 涨停股 的位置

							if( m < codeArray.length){
								setTimeout(loop, 1);
							}	 

						};

					}
					document.getElementById("PriceDate").value = tt;
					ranking();					
				}				
			}

			function jjiabkgg(codeName){
				            var ss = codeName.split(".");
							var code =ss[0];
							var name =ss[1];
				            var url2 = "https://apphq.longhuvip.com/w1/api/index.php?st="+成分数量+"&Index=0&IsKZZType=0&old=1&Order=1&a=ZhiShuStockList_W8&apiv=w35&Type=6&c=ZhiShuRanking&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-394d-fc3a-0a05-000004938839&PlateID=" + code + "&"; 		
	
							//alert('jp'+code);

							var num=0;  //涨停数 ，这里是统计 竞价期间 一字情况
							var 一字板数=0;
							var 跌停一字数=0;
							var 主板涨幅大于5数=0;
							var 主板涨幅小于5数=0; 
							var 创业板涨幅大于10数=0;
							var 成分总数=0;
							var lbzgNum=0;
							var lbzgName='';	
							var lbzgCode='';
							var zgNum=0;	 
							var zgName='';	
							var zgBNum='';
							var zgCode=''; 

							$.ajax({
								type: "get",
								url: url2,
								dataType: "json",
								async : false,
								cache:false,
								timeout:3000,
								success: function(data) { 
									成分总数 = data.Count;
									for (i = 0; i < data.list.length; i++){
										var aa = data.list[i];  
										
										var dmcode = aa[0].trim();
										var gpname = aa[1].trim();
										var zhangting=aa[23].trim();

										//st跳过
										if(gpname.toLowerCase().includes('st')) {
											continue;
										}

										//昨天涨停
										if(zhangting.toLowerCase().includes('昨') || zhangting=="") {
											continue;
										}

										num ++;

										// if(aa[28]>0){
										// 	num ++;  //涨停数
										// }  	


										// if(aa[0].substr(0,2)==="00" || aa[0].substr(0,2)==="60"){
										// 	var zf=aa[6];
										// 	if (zf>=5){
										// 		主板涨幅大于5数 ++;
										// 	}

										// 	if (zf<=-5){
										// 		主板涨幅小于5数 ++;
										// 	}
										// }

										// if(aa[0].substr(0,2)==="30"){
										// 	var zf=aa[6];
										// 	if (zf>=10){
										// 		创业板涨幅大于10数 ++;
										// 	} 
										// } 

										// if(aa[28]>0 && aa[33]==0){
										// 	一字板数 ++;  //一字板数
										// }  	

										// if(aa[6]<-8 && aa[33]==0){
										// 	跌停一字数 ++;  //一字板数
										// }
											
											
										// // 获取原始字符串
										var originalString = aa[23].trim();
										// 使用正则表达式匹配开头的数字
										var regex = /^\d+/; 

										// 提取的数字，如果存在的话 ， N 连扳
										var lianban = /^[0-9]{1,}连板$/.test(originalString.toString());
										if(lianban){
											var match = originalString.match(regex);
											var extractedNumber = match ? match[0] : '';
											var nn = parseInt(extractedNumber);
											if(nn> 0){
											if(lbzgNum<nn){
												lbzgNum=extractedNumber;
												lbzgName=aa[1].trim();
												lbzgCode=dmcode;
												}
											}
										}

										// 提取的数字，如果存在的话 ，N 天N 扳
										var match = originalString.match(regex);
										var extractedNumber = match ? match[0] : '';
										var nn = parseInt(extractedNumber);
										if(nn> 0){
										if(zgNum<nn){
											zgNum=extractedNumber;
											zgName=aa[1].trim();
											zgCode=dmcode;
											zgBNum=originalString.replace('天',',').replace('板','')
											} 
										}
										
									}	 						
								}
							});	 

							//板块最强个股

							if(num==0) return;

							var faselements = document.getElementById('jp'+code);  
							if(faselements!=null){   

								var elements_bk = faselements.querySelector('#bk'+name);  

								if(elements_bk!=null) {
								//涨幅占比
								var zbi = (100*主板涨幅大于5数/成分总数).toFixed(1)+"%"; 
								var zhangfu5zhanbi="[<font color=#f4fa3d;><strong>" + zbi + "</strong></font>]"; 
								var zhubanzf5shu="";  

								var cybzf10shu="";  

								if(主板涨幅大于5数>0){
									zhubanzf5shu="[<font color="+主板涨幅大于5数颜色+";><strong>" + 主板涨幅大于5数 + "</strong></font>]";    
								}

								if(创业板涨幅大于10数>0){
									cybzf10shu="[<font color="+创业板涨幅大于10数颜色+";><strong>" + 创业板涨幅大于10数 + "</strong></font>]";  
								}

								elements_bk.innerHTML+=zhubanzf5shu+cybzf10shu;

								};


								var elements = faselements.querySelector('#jpzt'+code);  

                                if(elements==null) return; 

								

								var zhangtshuj = "["+num+"]"; 
 	

								if(首板数>0){
									zhangtshuj=首板数+zhangtshuj;
								}

								if(一字板数>0){
									zhangtshuj=zhangtshuj+"[<font color=#ffffff;><strong>" + 一字板数 + "</strong></font>"+"]"; 
								}
								
								if(跌停一字板数>0){
									zhangtshuj=zhangtshuj+"[<font color=#00ff00;><strong>" + 跌停一字板数 + "</strong></font>"+"]"; 
								}
								

								elements.innerHTML = zhangtshuj; 
								elements.style.right = 涨停数的位置; 
								if(num>10){
									elements.style.color = 'red';  
								} 
								
								if(zgCode==lbzgCode){
									var blink = document.createElement('a');
									blink.id = "jpzt"+zgCode;
									blink.style.position = 'absolute';
									blink.style.right = 高标位置;
									var zgb = zgName + "["+zgNum +"]"; 
									if('[0]'!=zgb){
										blink.textContent = zgb; 
										blink.href = "http://www.treeid/code_"+zgCode; 
										if(zgNum>6){
											blink.style.color = "#FF0000";
										} 
									}else{
										blink.innerHTML = "";
									} 
									faselements.appendChild(blink);
								}else{
									var zgb1 = lbzgName.replace('*','').substring(0, 2) + "["+lbzgNum +"] "
									var zgb2 = " "+zgName.replace('*','').substring(0, 2) + "["+zgBNum +"]";
									if('[0]'!=zgb1.trim() && '[0]'!=zgb2.trim()){
										var blink = document.createElement('a');
										blink.id = "jpzt"+lbzgCode;
										blink.style.position = 'absolute';
										blink.style.right = 高标位置;
										blink.textContent = zgb1; 
										blink.href = "http://www.treeid/code_"+lbzgCode;
										if(lbzgNum>6){
											blink.style.color = "#FF0000";
										} 

										faselements.appendChild(blink);

										var clink = document.createElement('a');
										clink.id = "jpzt"+zgCode;
										clink.style.position = 'absolute';
										clink.style.right = N天N板;
										clink.textContent = zgb2; 
										clink.href = "http://www.treeid/code_"+zgCode;
										if(zgNum>6){
											clink.style.color = "#FF0000";
										} 

										faselements.appendChild(clink);

									}else{
										if('[0]'!=zgb1.trim() && '[0]'==zgb2.trim()){
											var blink = document.createElement('a');
											blink.id = "jpzt"+lbzgCode;
											blink.style.position = 'absolute';
											blink.style.right = 高标位置;
											blink.textContent = zgb1; 
											blink.href = "http://www.treeid/code_"+lbzgCode;
											if(lbzgNum>6){
												blink.style.color = "#FF0000";
											} 

											faselements.appendChild(blink);

										}
										if('[0]'!=zgb2.trim() && '[0]'==zgb1.trim()){
											var blink = document.createElement('a');
											blink.id = "jpzt"+zgCode;
											blink.style.position = 'absolute';
											blink.style.right = 高标位置;
											blink.textContent = zgb2; 
											blink.href = "http://www.treeid/code_"+zgCode;
											if(zgNum>6){
												blink.style.color = "#FF0000";
											} 

											faselements.appendChild(blink);
										}
									} 

								}

							}


							// var elements = document.getElementById('jpzt'+code);  
							// if(elements!=null){
							// 	elements.innerHTML= elements.innerHTML.replace('%',"% [ "+num+" ]");	
							// 	//涨停数 大于 10 变红
							// 	if(num>10)
							// 	elements.style.color = 'red';
							// }
							

			}
			

			function bkgg(codeName){
				            var ss = codeName.split(".");
							var code =ss[0];
							var name =ss[1];
				            var url2 = "https://apphq.longhuvip.com/w1/api/index.php?st="+成分数量+"&Index=0&IsKZZType=0&old=1&Order=1&a=ZhiShuStockList_W8&apiv=w35&Type=6&c=ZhiShuRanking&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-394d-fc3a-0a05-000004938839&PlateID=" + code + "&"; 		
	
							//alert('jp'+code);

							var num=0;
							var 首板数=0;
							var 一字板数=0;
							var 跌停一字数=0;
							var 主板涨幅大于5数=0;
							var 主板涨幅小于5数=0; 
							var 创业板涨幅大于10数=0;
							var 成分总数=0;
							var lbzgNum=0;
							var lbzgName='';	
							var lbzgCode='';
							var zgNum=0;	 
							var zgName='';	
							var zgBNum='';
							var zgCode=''; 

							$.ajax({
								type: "get",
								url: url2,
								dataType: "json",
								async : false,
								cache:false,
								timeout:3000,
								success: function(data) { 
									成分总数 = data.Count;
									for (i = 0; i < data.list.length; i++){
										var aa = data.list[i];  
										
										var dmcode = aa[0].trim();
										var gpname = aa[1].trim();
										var zhangting=aa[23].trim();   //涨停 连板情况

										//st跳过
										if(gpname.toLowerCase().includes('st')) {
											continue;
										}


										if(aa[28]>0 || (zhangting!="" & !zhangting.toLowerCase().includes('昨'))){
											num ++;  //涨停数
										}  

										if(zhangting==="首板"){
											首板数 ++;
										}

										if(aa[0].substr(0,2)==="00" || aa[0].substr(0,2)==="60"){
											var zf=aa[6];
											if (zf>=5){
												主板涨幅大于5数 ++;
											}

											if (zf<=-5){
												主板涨幅小于5数 ++;
											}
										}

										if(aa[0].substr(0,2)==="30"){
											var zf=aa[6];
											if (zf>=10){
												创业板涨幅大于10数 ++;
											} 
										} 

										if(aa[28]>0 && aa[33]==0){
											一字板数 ++;  //一字板数
										}  	

										if(aa[6]<-8 && aa[33]==0){
											跌停一字数 ++;  //一字板数
										}
											
											
										// 获取原始字符串
										var originalString = aa[23].trim();
										// 使用正则表达式匹配开头的数字
										var regex = /^\d+/; 

										// 提取的数字，如果存在的话 ， N 连扳
										var lianban = /^[0-9]{1,}连板$/.test(originalString.toString());
										if(lianban){
											var match = originalString.match(regex);
											var extractedNumber = match ? match[0] : '';
											var nn = parseInt(extractedNumber);
											if(nn> 0){
											if(lbzgNum<nn){
												lbzgNum=extractedNumber;
												lbzgName=aa[1].trim();
												lbzgCode=dmcode;
												}
											}
										}

										// 提取的数字，如果存在的话 ，N 天N 扳
										var match = originalString.match(regex);
										var extractedNumber = match ? match[0] : '';
										var nn = parseInt(extractedNumber);
										if(nn> 0){
										if(zgNum<nn){
											zgNum=extractedNumber;
											zgName=aa[1].trim();
											zgCode=dmcode;
											zgBNum=originalString.replace('天',',').replace('板','')
											} 
										}
										
											
									}	 						
								}
							});	 

							//板块最强个股

							if(num==0) return;

							var faselements = document.getElementById('jp'+code);  
							if(faselements!=null){   

								var elements_bk = faselements.querySelector('#bk'+name);  

								if(elements_bk!=null) {
								//涨幅占比
								var zbi = (100*主板涨幅大于5数/成分总数).toFixed(1)+"%"; 
								var zhangfu5zhanbi="[<font color=#f4fa3d;><strong>" + zbi + "</strong></font>]"; 
								var zhubanzf5shu="";  

								var cybzf10shu="";  

								if(主板涨幅大于5数>0){
									zhubanzf5shu="[<font color="+主板涨幅大于5数颜色+";><strong>" + 主板涨幅大于5数 + "</strong></font>]";    
								}

								if(创业板涨幅大于10数>0){
									cybzf10shu="[<font color="+创业板涨幅大于10数颜色+";><strong>" + 创业板涨幅大于10数 + "</strong></font>]";  
								}

								elements_bk.innerHTML+=zhubanzf5shu+cybzf10shu;

								};


								var elements = faselements.querySelector('#jpzt'+code);  

                                if(elements==null) return;



								

								var zhangtshuj = "["+num+"]"; 
 	

								if(首板数>0){
									zhangtshuj=首板数+zhangtshuj;
								}

								if(一字板数>0){
									zhangtshuj=zhangtshuj+"[<font color=#ffffff;><strong>" + 一字板数 + "</strong></font>"+"]"; 
								}
								
								if(跌停一字数>0){
									zhangtshuj=zhangtshuj+"[<font color=#00ff00;><strong>" + 跌停一字数 + "</strong></font>"+"]"; 
								}
								

								

								elements.innerHTML = zhangtshuj; 
								elements.style.right = 涨停数的位置; 
								if(num>10){
									elements.style.color = 'red';  
								} 
								
								if(zgCode==lbzgCode){
									var blink = document.createElement('a');
									blink.id = "jpzt"+zgCode;
									blink.style.position = 'absolute';
									blink.style.right = 高标位置;
									var zgb = zgName + "["+zgNum +"]"; 
									if('[0]'!=zgb){
										blink.textContent = zgb; 
										blink.href = "http://www.treeid/code_"+zgCode; 
										if(zgNum>6){
											blink.style.color = "#FF0000";
										} 
									}else{
										blink.innerHTML = "";
									} 
									faselements.appendChild(blink);
								}else{
									var zgb1 = lbzgName.replace('*','').substring(0, 2) + "["+lbzgNum +"] "
									var zgb2 = " "+zgName.replace('*','').substring(0, 2) + "["+zgBNum +"]";
									if('[0]'!=zgb1.trim() && '[0]'!=zgb2.trim()){
										var blink = document.createElement('a');
										blink.id = "jpzt"+lbzgCode;
										blink.style.position = 'absolute';
										blink.style.right = 高标位置;
										blink.textContent = zgb1; 
										blink.href = "http://www.treeid/code_"+lbzgCode;
										if(lbzgNum>6){
											blink.style.color = "#FF0000";
										} 

										faselements.appendChild(blink);

										var clink = document.createElement('a');
										clink.id = "jpzt"+zgCode;
										clink.style.position = 'absolute';
										clink.style.right = N天N板;
										clink.textContent = zgb2; 
										clink.href = "http://www.treeid/code_"+zgCode;
										if(zgNum>6){
											clink.style.color = "#FF0000";
										} 

										faselements.appendChild(clink);

									}else{
										if('[0]'!=zgb1.trim() && '[0]'==zgb2.trim()){
											var blink = document.createElement('a');
											blink.id = "jpzt"+lbzgCode;
											blink.style.position = 'absolute';
											blink.style.right = 高标位置;
											blink.textContent = zgb1; 
											blink.href = "http://www.treeid/code_"+lbzgCode;
											if(lbzgNum>6){
												blink.style.color = "#FF0000";
											} 

											faselements.appendChild(blink);

										}
										if('[0]'!=zgb2.trim() && '[0]'==zgb1.trim()){
											var blink = document.createElement('a');
											blink.id = "jpzt"+zgCode;
											blink.style.position = 'absolute';
											blink.style.right = 高标位置;
											blink.textContent = zgb2; 
											blink.href = "http://www.treeid/code_"+zgCode;
											if(zgNum>6){
												blink.style.color = "#FF0000";
											} 

											faselements.appendChild(blink);
										}
									} 

								}

							}


							// var elements = document.getElementById('jpzt'+code);  
							// if(elements!=null){
							// 	elements.innerHTML= elements.innerHTML.replace('%',"% [ "+num+" ]");	
							// 	//涨停数 大于 10 变红
							// 	if(num>10)
							// 	elements.style.color = 'red';
							// }
							

			}
			
			//子类
			function subclass(bkdm , bks) {
				var url3 = "https://apphq.longhuvip.com/w1/api/index.php?a=SonPlate_Info&c=ZhiShuRanking&apiv=w26&PhoneOSNew=1&PlateID=" + bkdm + "&"; 

				var url4 = "https://apphis.longhuvip.com/w1/api/index.php?a=SonPlate_Info&c=ZhiShuRanking&IsShow=1&apiv=w26&PlateID=" + bkdm + "&Date=" + tt + "&";					
				var url = url3;
				if(k == "1"){
					url = url4;
				}				
				var xhr = new XMLHttpRequest();	
				xhr.open("GET", url, false);//同步 
				xhr.send(null)																		
				div1 = document.getElementById('towrite1');
				//div1.innerHTML = div1.innerHTML + "<ul><li>" + bks + "</li></ul>";
				var data3 = xhr.responseText;						
				if(data3.indexOf('\"List\":[]') == -1) {
				
					var dms = bks.split('、');					
					div1.innerHTML = div1.innerHTML + "<p id=jp"+bkdm+">" + dms[0] + ".★" + dms[1] + "</p>";
					
					//添加分类Div
					var newDiv = document.createElement("div");
					newDiv.id = bkdm;
					newDiv.style.display = "none";
					document.getElementById("towrite1").appendChild(newDiv);
						
					//data3 = data3.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
					data3 = data3.replace(/ /g,"").match(/\{\"List\":(\S*)\]\],\"/)[1] + ']]';	
					data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"qd":'+str.split(',')[2];});							
					data3 = data3.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");
					//alert(data3);	
					//document.write(data3);

					var result = JSON.parse(data3); //JSON字符串转换为对象
					function up(a,b){
					return b.qd-a.qd
					}
					result.sort(up);
					result = JSON.stringify( result );						
					data3= '{\"List\":' + result + "}";
					//document.write(data3);

					var transform_ee1 = [           
					{"tag":"p", children:function(){return(json2html.transform(this.List, transform_ff1));}}
					];

					var transform_ff1= 
					{"tag":"p", children:[
					{"tag":"p", children:[
					//{"tag": "li", "html":"<a href='javascript:void(0)' id='" + bkdm + "' onclick='changeCss(this,this.id);update(\"${code}\"+\"#\"+\"${name}\")'>${code} ${name}&nbsp;&nbsp;强度：${qd}</a>"}
					{"tag": "li", "html":"<a href='javascript:void(0)' id='" + bkdm + "' onclick='changeCss(this,this.id);update(\"${code}\"+\"#\"+\"${name}\")'>${name}&nbsp;&nbsp;&nbsp;&nbsp;${qd}</a>"}	
				]}]};

					var html3 = json2html.transform(data3, transform_ee1);		
					//div1 = document.getElementById('towrite1');
					div1 = document.getElementById(bkdm);
					div1.innerHTML = div1.innerHTML + html3;				
				}else{
					div1.innerHTML = div1.innerHTML +  "<p id=jp"+bkdm+">" + bks + "</p>";
				}							
			}

			/*
			* param str 要截取的字符串
			* param L 要截取的字节长度，注意是字节不是字符，一个汉字两个字节
			* return 截取后的字符串
			*/
			function cutStr(str,L){    
				var result = '',
					strlen = str.length, // 字符串长度
					chrlen = str.replace(/[^\x00-\xff]/g,'**').length; // 字节长度

				if(chrlen<=L){return str;}
				
				for(var i=0,j=0;i<strlen;i++){
					var chr = str.charAt(i);
					if(/[\x00-\xff]/.test(chr)){
						j++; // ascii码为0-255，一个字符就是一个字节的长度
					}else{
						j+=2; // ascii码为0-255以外，一个字符就是两个字节的长度
					}
					if(j<=L){ // 当加上当前字符以后，如果总字节长度小于等于L，则将当前字符真实的+在result后
						result += chr;
					}else{ // 反之则说明result已经是不拆分字符的情况下最接近L的值了，直接返回
						return result;
					}
				}
			}

			//加入板块
			function copyintobak(){ 
				var divElement = document.getElementById('towrite2');
				var aElements = divElement.querySelectorAll('a');
				// 遍历并处理所有a元素
				var numberParts = "";
				aElements.forEach(a => {
					const parts = a.href.split('_');
					if(parts.length>1) {
						var numberPart = parts[1];
						if(numberPart.substring(0, 1) === '0' ||  numberPart.substring(0, 1) === '3')
						numberPart='0#'+numberPart;

						if(numberPart.substring(0, 1) === '6')
						numberPart='1#'+numberPart; 

						if(numberPart.substring(0, 1) === '4' ||  numberPart.substring(0, 1) === '8' ||  numberPart.substring(0, 1) === '9')
						numberPart='2#'+numberPart; 

						numberParts+=numberPart;
						numberParts+="|"; 
						
					} 
					
				});
				
				numberParts=numberParts.trim('|');
				window.location.href='http://www.treeid/AddToBlock_'+numberParts; 
			}
			
			var temp = "";
			var bdm = "";
			var bkm = "";	
			var y = 1;
			var olddm="";
			var oldbk="";
			var numnum=0;
			function update(ss) {
				y = 1;
				numnum++;
				//alert(ss);
				if(ss != "0" ){
					var dms=ss.split('#');
					dm = dms[0];
					if(dm != olddm){
						numnum = 1;
					}
					olddm=dm;
					bk = dms[1];
					oldbk=bk;
					bdm = dm;
					bkm = bk;					

					//缓存一个消息 方便搜索 ,换成一个消息
					localStorage.setItem('message', cutStr(bkm.replace('%',''),16));
 
					//点两次 打开 显示
					
					if(document.getElementById(dm)){					
						div1 = document.getElementById(dm);
						if(temp.indexOf(dm) == -1 && numnum>=2){
							numnum=0;
							temp += dm + ";";
							div1.style.display = "block";
							div1.style.paddingLeft = '20px';
						}else{
							temp = temp.replace(dm + ";" , "");
							div1.style.display = "none";
						}
					}
						
					
				}

				var sx2 = "<a style='position:absolute; right:-15px;' href='javascript:void(0)' onclick='copyintobak()'>+板块</a>";	
				var bfyy = "<a style='position:absolute; right:75px;' href='javascript:void(0)' onclick='updateb()'>【原因】</a>";
				var zz = "<a style='position:absolute; right:33px;' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";
				var ggxq = "<a href='http://www.treeid/dlglocalurl##homepath##company/ggxq.html##xxxxxx####STOCKNAME##' style='float:right;margin-right:35px;font-size:10px;'>详情</a>";
				var jbm = "<a href='http://www.treeid/dlglocalurl##homepath##company/" + encodeURI('基本面') + ".html##xxxxxx####STOCKNAME##' style='float:right;margin-right:0px;font-size:10px;'>基本面</a>";				
				
				div2 = document.getElementById('towrite2');				
				div2.innerHTML = '<h4>' + bk.replace('汽车零部件','汽配') + bfyy + zz+sx2 + '</h4>'; // ggxq + jbm + '</h4>';			
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st="+成分数量+"&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=5ff59eba-ca99-34f8-a47b-fd7e53423aad&VerSion=5.13.0.2&IsZZ=0&Token=0&Index=0&apiv=w35&Type=6&IsKZZType=0&UserID=0&PlateID=" + dm + "&"; 								
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?st="+成分数量+"&Index=0&old=1&Order=1&a=ZhiShuStockList_W8&apiv=w26&Type=6&c=ZhiShuRanking&PlateID=" + dm + "&Date=" + tt + "&"				
				var url = url1;
				if(k == "1"){
					url = url2;
				}			
				createXmlHttp();
				xmlHttp2.onreadystatechange = writeSource2;				
				xmlHttp2.open("GET", url, true);
				xmlHttp2.send(null);				
			}
			
			function writeSource2() { 			
				if (xmlHttp2.readyState == 4) {                  	
				var data2 = xmlHttp2.responseText
				//document.write(data2);
				//data2 = data2.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
				data2 = data2.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';	
				//data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"zf":'+str.split(',')[6];});
				data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ 
				str = word.match(/\[(\S*)/)[1]; 
				return '{"code":' + str.split(',')[0] + 
				',"name":' + str.split(',')[1] +
				',"zf":'+str.split(',')[6] +
				',"zs":'+str.split(',')[9] +
				',"lz":'+str.split(',')[24] +
				',"zl":'+str.split(',')[2] +
				',"lb":'+str.split(',')[23] + 
				',"sjlt":'+str.split(',')[10] +
				',"zt":'+str.split(',')[39] +
				',"fd":'+str.split(',')[28] +
				',"yz":'+str.split(',')[33];});  //yz  一字板
				
				//data2 = '{\"list\":' + data2.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]") + "}";
				data2 = data2.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");					
				//document.write(data2);
				
				var json = JSON.parse(data2);
					
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var v = 0;
				var b = 0;
				var gl = "领涨";  //高亮
				for(var key in json[0]){  //表头													
					key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('zl','主力').replace('lz','领涨');
					key = key.replace('lb','连板').replace('zt','主题').replace('zs','速%').replace('sjlt','市值z').replace('fd','封单');
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);					
					if(key == "领涨"){
						b = m;							
						th.style.color = "#FFA500";
						
					}else if(key == "主力" || key == "连板" || key == "主题"){
						th.style.color = "#FFA500";	
					}
					if(gl == key.replace("%","")){
						v = m;
						th.style.color = "#FF6633";	
					}
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				for(var i = 0; i < json.length; i++){				
					
					//st 不处理
					if(json[i]["name"].toLowerCase().includes('st')){
						 continue;
						}

					var tr=document.createElement("tr");						
					var p = 1;	
					var dm = "";
					var mc = "";  

					for(var key in json[i]){ //行元素遍历	
						
						var td=document.createElement("td");	
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;
						}else if(p == 4){
							rc = keepTwoDecimal(rc);
						}

						if(key=="fd" || key=="sjlt"){
								let a=0;
								if(rc>=100000000){
									let k = (rc / 100000000);
									// 先以 a=2 进行计算
									let tempK = k.toFixed(2);
									if (tempK.length > 5) {
										a = 0;
									} else {
										a = 2;
									}

									rc=(rc/100000000).toFixed(a)+"亿";

								}else{
									rc=(rc/10000).toFixed(a)+"万";
								} 
						} 

						if(key=="zf"){
							var rcfd = json[i]["fd"];
							if(rcfd>0){ 
								let a=0;
								if(rcfd>=100000000){
									let k = (rcfd / 100000000);
									// 先以 a=2 进行计算
									let tempK = k.toFixed(2);
									if (tempK.length > 5) {
										a = 0;
									} else {
										a = 2;
									}
									rc=(rcfd/100000000).toFixed(a)+"亿";
								}else{
									rc=(rcfd/10000).toFixed(a)+"万";
								} 
							} 
						}
						
						if(key=="lb"){
							rc=rc.replace('天',',').replace('日','').replace('连','').replace('首','1');
							var zb = json[i]["lz"];
							if (zb=="破板"){
								rc = zb;  
							} 
						} 

						if(key=="zs"){
							var yz = json[i]["yz"];
							var fd = json[i]["fd"];
							var zf = json[i]["zf"];
							if ((fd>0 && yz==0) || (yz==0 && zf<-8)){
								rc = "一字";  
							} 

							if (yz==0 && zf==0){
								rc = "停牌";  
							}
						} 

						if(key=="zt"){
							rc = cutStr(rc.replace('绿色','绿').replace('电力','电').replace('黄金','金').replace('概念',''),6);  
						} 

						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeTCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
						
						if(key=="zf"){
							var fd = json[i]["fd"];
							var sjlt=json[i]["sjlt"];
							if(fd>0){
								td.getElementsByTagName("a")[0].style.color = "#fc780d"; // 橙色
							}

							//封单 占实际市值 5%  标红
							if(fd/sjlt > 封占比){
								td.getElementsByTagName("a")[0].style.color = "#fd0303"; // 红色
								td.getElementsByTagName("a")[0].style.fontWeight='bold';
							}
							
						}

						if(key=="zs"){
							var yz = json[i]["yz"];
							var zf = json[i]["zf"];
							var fd = json[i]["fd"];
							if (fd>0 && yz==0){
								td.getElementsByTagName("a")[0].style.color = "yellow"; // 红色
								td.getElementsByTagName("a")[0].style.fontWeight='bold';
							}  

							if (yz==0 && zf<-8){
								td.getElementsByTagName("a")[0].style.color = "#00ff00"; 
								td.getElementsByTagName("a")[0].style.fontWeight='bold';
							} 
						} 

						if(key=="lb"){
							var zb = json[i]["lz"];

							var lianban = /[2-5]{1}板$/.test(rc.toString());
							if(lianban){
								td.getElementsByTagName("a")[0].style.color = "#fc780d"; // 橙色
							}

							//td.getElementsByTagName("a")[0].style.color = "#fc780d"; // 橙色

							if (zb=="破板"){ 
								td.getElementsByTagName("a")[0].style.color = "#00ff00"; //绿色
							} 

						    lianban = /[6-9]{1}板$/.test(rc.toString()) || /[0-9]{2}板$/.test(rc.toString());
							if(lianban){
								td.getElementsByTagName("a")[0].style.color = "#fd0303"; // 红色
							}

						}
						
						// 300 688 689 301 变色  创业板颜色  设置   下面 还有一个地方 改颜色
						if(dm.substr(0,2)=="30" ){
							tr.style.backgroundColor  = cybcolor;
							//2F4F4F
						}
						
						//科创板颜色  设置
						if(dm.substr(0,2)=="68"){
							tr.style.backgroundColor  = kcbcolor;
							//2F4F4F
						}

						if(p >= b + 1){							
							//td.getElementsByTagName("a")[0].style.color = "#FFA500";   //背景颜色  灰白
							td.width = "100px";								
						}
						if(p == v + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";
						}		
						
						if(key=="sjlt"){
								var sjsz=json[i]["sjlt"];
								//封单 占实际市值 5%  标红
								if((sjsz/100000000) <= 实际流通标签){
										td.getElementsByTagName("a")[0].style.color = 实际流通标签颜色; // 
										td.getElementsByTagName("a")[0].style.fontWeight='bold';
									}
						}

						var _width="";
						if(key=="name"){
							_width = "50px";
							td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						}  
						if(key=="zf"){
							_width = "40px";
							td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						}  

						if(key=="zs"){
							_width = "28px";
							td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						} 

						if(key=="zt"){
							_width = "40px";
							td.style="min-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						} 

						if(key=="lb"){
							_width = "33px";
							td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						}  

						if(key=="sjlt"){
							_width = "45px";
							td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
						}   

						tr.appendChild(td);
						p++;
					}						
					tbody.appendChild(tr);
				}		

				var div = document.getElementById("towrite2");
				div.style.whiteSpace = "nowrap";				
				div.appendChild(table);
				table.id = "gg";		 
				changeTable(table,"0#4#5#9#10");	 //隐藏列
				var table=document.getElementsByTagName("table")[0];
				makeSortable(table);			
				hover();
				}
			}

			//隐藏某列				
            function changeTable(table,ss) {	
				var trs = table.rows;
				ss = ss + '#';
				var aa = ss.split('#');
				for (var j = 0; j < aa.length; j++) {
					if(aa[j] != ""){
						for (var i = 0, len = trs.length; i < len; i++) {					
							var p = aa[j];
							var cell = trs[i].cells[p]; 
							cell.style.display = 'none';
						}
					}
				}					
			}
			
			var f = 1;
			function makeSortable(table) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
							//alert(n);	
							//alert(f);	
							//showCol(n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("主力") != -1|| headtxt.indexOf("主题") != -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt.indexOf("连板") != -1){								
									val1 = val1.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val1.indexOf("天")>-1){
										val1 = val1.split("天")[0];
									}else if(val1.indexOf("昨")>-1){
										val1 = 0;
									}else if(val1 == ""){
										val1 = -2;
									}										
									val1 = parseFloat(val1);
								
									val2 = val2.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val2.indexOf("天")>-1){
										val2 = val2.split("天")[0];
									}else if(val2.indexOf("昨")>-1){
										val2 = 0;
									}else if(val2 == ""){
										val2 = -2;
									}									
									val2 = parseFloat(val2);
								}else if(headtxt.indexOf("领涨") != -1){
									val1 = val1.replace("龙十","龙一十").replace("破板","1000");
									val2 = val2.replace("龙十","龙一十").replace("破板","1000");
									if(val1 == ''){
										val1 = '1001';
									}
									if(val2 == ''){
										val2 = '1001';
									}
									if(val1.indexOf("龙") != -1){
										val1 = ChineseToNumber(val1.replace("龙",""));										
									}										
									if(val2.indexOf("龙") != -1){
										val2 = ChineseToNumber(val2.replace("龙",""));
										
									}
									//val2 = parseFloat(val2);									
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
								
							});
							if(flag){
								rows.reverse();								
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
							f = f * (-1);
						}
					}(i));
				}
			}
			
			function showCol(iCol){			
				var oTable = document.getElementsByTagName('table')[0];
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#d2d2d3";
						
						oTable.rows[i].cells[4].style.color = "#FFA500"; 
						oTable.rows[i].cells[5].style.color = "#FFA500";
						oTable.rows[i].cells[6].style.color = "#FFA500";
						oTable.rows[i].cells[7].style.color = "#FFA500";						
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}

				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#d2d2d3";
					if(otagsA[i].id >= 5){
						otagsA[i].style.color = "#FFA500";								
					}
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}								
			}
			
			var chnNumChar = {零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9};

			var chnNameValue = {
			  十:{value:10, secUnit:false},
			  百:{value:100, secUnit:false},
			  千:{value:1000, secUnit:false},
			  万:{value:10000, secUnit:true},
			  亿:{value:100000000, secUnit:true}
			}

			function ChineseToNumber(chnStr){
			  var rtn = 0;
			  var section = 0;
			  var number = 0;
			  var secUnit = false;
			  var str = chnStr.split('');

			  for(var i = 0; i < str.length; i++){
				var num = chnNumChar[str[i]];
				if(typeof num !== 'undefined'){
				  number = num;
				  if(i === str.length - 1){
					section += number;
				  }
				}else{
				  var unit = chnNameValue[str[i]].value;
				  secUnit = chnNameValue[str[i]].secUnit;
				  if(secUnit){
					section = (section + number) * unit;
					rtn += section;
					section = 0;
				  }else{
					section += (number * unit);
				  }
				  number = 0;
				}
			  }
			  return rtn + section;
			}

			function changeCss(obj,id){				
				var alist = document.getElementById(id).getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){				
					if(alist[i] == undefined){
						break;
					}

					if(alist[i].id.includes("jpzt")){
						continue;
					} 

					alist[i].style.color = "#d2d2d3"; //给所有a标签赋原色
				}
				ranking();
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			var trid = ""; 
			function changeTCss(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");			
				for(var i=0;i<tlist.length;i++){
					if(hid != ""){  //过滤表头
							tlist[i].style.background="#000000";  //背景颜色  改回默认
							if(hid != trid){  //过滤选中行 
								//改创业板 颜色
								if(tlist[i].id.substr(0,2)=="30"){		 
									tlist[i].style.backgroundColor = cybcolor; 
								} 

								// //改科创板 颜色
								if(tlist[i].id.substr(0,2)=="68"){		 
									tlist[i].style.backgroundColor = kcbcolor; 
								} 
								
							}
						}
				}

				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = 选中的颜色;
										
			}
			
			function hover(){  //鼠标经过
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background="#000000";   //背景颜色  改回默认
								//改创业板 颜色
								if(this.id.substr(0,2)=="30"){		 
									this.style.backgroundColor = cybcolor;
								}else{
									//this.style.backgroundColor = bkcolor;
									//this.style.background="#000000";
								}	

								// //改科创板 颜色
								if(this.id.substr(0,2)=="68"){		 
									this.style.backgroundColor = kcbcolor;
								}else{
									//this.style.backgroundColor = bkcolor;
								}
								
							}else{
								this.style.background=选中的颜色; 
							}
						}						
					}					
				}
			}			
			
			function ranking(){				
				var alist = document.getElementById("towrite1").getElementsByTagName("a");
				var filters = "业绩增长,ST板块,并购重组,年报增长";				
				var p = 1;
				for(var i = 0; i < alist.length; i++){				
					var bk = alist[i].id;
					if(bk.indexOf('bk') > -1){
						bk = bk.replace('bk','');
						if(filters.indexOf(bk) == -1){						
							if(p == 1){
								alist[i].style.color = "#FF00FF";  //排名1颜色
							}
							if(p == 2){
								alist[i].style.color = "#FFFF00";  //排名2颜色
							}
							if(p == 3){
								alist[i].style.color = "#00FF00";  //排名3颜色
							}
							p++
							if(p == 4){
								p = 1;
								break;
							}
						}					
					}	
				}				
			}
			
			
			function updatez() {
				var dm = bdm; 			 						
				var url3 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&ZZ=1&a=PlateIntroduction&st=60&c=ZhiShuRanking&Index=0&apiv=w24&Type=2&PlateID=" + dm + "&"; 								
				var url4 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=60&c=ZhiShuRanking&IsZZ=1&Index=0&apiv=w26&Type=6&PlateID=" + dm + "&Date=" + tt + "&"; 
				var url = url3;
				if(k == "1"){
					url = url4;
				}							
				if (window.XMLHttpRequest) {
				xmlHttp3 = new XMLHttpRequest();				
				} else {
				xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp3.onreadystatechange = writeSource3;				
				xmlHttp3.open("GET", url, true);
				xmlHttp3.send(null);				
			}
			
			function writeSource3() { 			
				if (xmlHttp3.readyState == 4) {                  	
				var data3 = xmlHttp3.responseText
				//document.write(data3);
				data3 = data3.replace(/ /g,"").replace("List","list").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';
				if(k == "0"){
					data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] + 
					',"zf":'+str.split(',')[3] + 
					',"lzcs":'+str.split(',')[4]});
				}else{				
					data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zf":'+str.split(',')[6] +
					',"lz":'+str.split(',')[24] +
					',"zl":'+str.split(',')[2] +
					',"lb":'+str.split(',')[23];});				
				}
				data3 = '{\"list\":' + data3.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]") + "}";				
				//document.write(data3);
				
				var transform_aa3 = [           
				{"tag":"p", children:function(){return(json2html.transform(this.list, transform_bb3));}}
				];
				
				var transform_bb3="";
				if(k == "0"){
					transform_bb3= 
					{"tag":"p", children:[
					{"tag":"p", children:[											
					{"tag": "p", "html":"<a href='http://www.treeid/code_${code}' onclick='changeCss(this,\"towrite2\")'>${code} ${name}&nbsp;涨幅:${zf}%&nbsp;领涨次数:${lzcs}</a>"}, 
					]}]}; 
				}else{
					transform_bb3= 
					{"tag":"p", children:[
					{"tag":"p", children:[											
					{"tag": "p", "html":"<a href='http://www.treeid/code_${code}' >${code} ${name}&nbsp;&nbsp;涨幅：${zf}%&nbsp;&nbsp;${lb}</a>"}, 
					]}]}; 
				}
				var html3 = json2html.transform(data3, transform_aa3);	
				var bfyy = "<a style='padding-left:35px;font-size:10px;' href='javascript:void(0)' onclick='updateb()'>【爆发原因】</a>";
				var qb = "<a style='float:right;margin-right:20px;font-size:10px;' href='javascript:void(0)' onclick='update(" + "0" + ")'>全部</a>";				
				div2 = document.getElementById('towrite2');				
				div2.innerHTML = '<h4>' + bk + bfyy + qb + '</h4>';										
				div2.innerHTML = div2.innerHTML + html3;
				div2.style.whiteSpace = "nowrap";
				}					
			}
			
			function updateb() {
				y = 0;	
				var dm = bdm; 			 
				//div2 = document.getElementById('towrite2');				
				//div2.innerHTML = '<h3>' + bk + '</h3>';
				var url4 = "https://apphq.longhuvip.com/w1/api/index.php?a=GetBaseFaceListZDEvnArtNew&apiv=w26&c=ZhiShuL2Data&VerSion=5.19.0.0&PhoneOSNew=1&DeviceID=ffffffff-2423-5c91-20a2-00000cae2a18&StockID=" + dm;				
				var url5 = "https://apphis.longhuvip.com/w1/api/index.php?a=GetDayBaseFaceListZDEvnArt&st=10&c=ZhiShuKLine&apiv=w26&VerSion=5.19.0.0&PhoneOSNew=1&DeviceID=ffffffff-2423-5c91-20a2-00000cae2a18&StockID=" + dm; 							
				
				if (window.XMLHttpRequest) {
				xmlHttp4 = new XMLHttpRequest();				
				} else {
				xmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp4.onreadystatechange = writeSource4;				
				xmlHttp4.open("GET", url4, true);
				xmlHttp4.send(null);
				
				if (window.XMLHttpRequest) {
				xmlHttp5 = new XMLHttpRequest();				
				} else {
				xmlHttp5 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp5.onreadystatechange = writeSource4;				
				xmlHttp5.open("GET", url5, true);
				xmlHttp5.send(null);								
			}
			
			function writeSource4() { 			
				if (xmlHttp4.readyState == 4 && xmlHttp5.readyState == 4) {                  	
					var data = xmlHttp4.responseText
					data = '{"List":[' + data + ']}';
					//document.write(data);	
					var fh = "<a style='padding-left:10px' href='javascript:void(0)' onclick='update(" + "0" + ")'>【返回】</a>";
					var zz = "<a style='float:right' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";				
					div2 = document.getElementById('towrite2');				
					div2.innerHTML = '<h4>' + bk + fh + zz + '</h4>';	
						
					if(data.indexOf('"Date":""') == -1){
						var rq = data.match(/\"Date\":\"(\S*)\",\"/)[1];						
						var day = new Date();
						gt = day.getTime();			
						mymonth = day.getMonth()+1;
						myday = day.getDate();
						if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
						if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
						tt = day.getFullYear() + "-" + mymonth + "-" + myday;													
						if(rq == tt){
							var transform_aa = [           
							{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
							];
							
							var transform_bb= 
							{"tag":"p", children:[
							{"tag":"li", children:[							
							{"tag": "b", "html":"${Date}：${BoomReason}"},
							{"tag": "p style=color:#c18a1d;font-size:10px;", "html":"${Title}"}, 								
							]}]}; 
							
							var html = json2html.transform(data, transform_aa);																						
							div2.innerHTML = div2.innerHTML + html;
						}
					}
					
					var data1 = xmlHttp5.responseText
					if(data1.indexOf('\"List\":[]') == -1){
						var transform_aa = [           
						{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
						];
						
						var transform_bb= 
						{"tag":"p", children:[
						{"tag":"li", children:[							
						{"tag": "b", "html":"${Date}：${BoomReason}"},
						{"tag": "p style=color:#c18a1d;font-size:10px;", "html":"${Title}"}, 								
						]}]}; 
						
						var html = json2html.transform(data1, transform_aa);					
						div2.innerHTML = div2.innerHTML + html;
					}else if(data1.indexOf('\"List\":[]') > -1 && data.indexOf('"Date":""') > -1){						
						div2.innerHTML = div2.innerHTML + "暂无数据";	
					}
					div2.style.whiteSpace = "normal";  //折行	
					
					

				}					
			}
			
		</script>
	</head>
	<body>		
		<div id="towriter" class="fixedBox">			
			<div id="towrite1" ></div>		
			<div id="towrite2" class="fixedBox" ></div>
		</div>
	</body>
</html>